package cn.lcsjsxy.yxc.miscellaneous;

import java.util.Scanner;
/**
 * 类和对象的创建
 * */
public class Person {
    public static void main(String[] args) {
        Per P1=new Per();  //创建对象
        P1.name = "Yxc";  //调用属性
        P1.isMale = true;

        P1.run();  //调用方法
        P1.myAge();
        P1.mySex();
        P1.setMyLikeName();
        P1.setMyNumber();
        P1.reversal();
        P1.找我的婉茗();
        P1.myFinalGrade();
        P1.sortMyNumber();

        //new com.yang_xc.miscellaneous.Per

        //*********************

//        com.yang_xc.miscellaneous.Per P2 = new com.yang_xc.miscellaneous.Per();
//        P2.name = "H";
//        P2.isMale = false;
//
//        P2.myName();
//        P2.myAge();
//
//        //********************
//
//        com.yang_xc.miscellaneous.Per P3=P1;
//        P3.myName();
//
//        P3.age=16;
//        P3.myAge();
    }
}
class Per{  //创建类
    String name;  //成员属性
    int age=17;
    boolean isMale;
    String []myLikeName = new String[]{"WanMing","ZhiQing","Bule","dei"};
    int [][]myNumber = new int[][]{{55,66,99},{11,22,33}};
    int []myNumber1 = new int[]{55,21,888,365};
    int finalGrade;

    public void run(){  //方法，行为
        System.out.println("人可以跑步");
    }
    public void myAge(){
        System.out.println("我的年龄是："+age);
    }
    public void myName(){
        System.out.println("我的名字是："+name);
    }
    public void mySex(){
        if(isMale) {
            System.out.println("我的性别是：男");
        }
        else {
            System.out.println("我的性别是：女");
        }
    }
    public void setMyLikeName(){
        for(int i=0;i<(myLikeName.length);i++){
            System.out.println(myLikeName[i]);
        }
    }
    public void reversal(){
        for(int i=0;i<myLikeName.length / 2;i++){
            String temp = myLikeName[i];
            myLikeName[i]=myLikeName[myLikeName.length-i-1];
            myLikeName[myLikeName.length-i-1]=temp;
        }
        for(int n=0;n<myLikeName.length;n++)
            System.out.print(myLikeName[n]+"  ");
        System.out.println();
    }

    public  void 找我的婉茗(){
        String name ="WanMing";
        for(int i=0;i<myLikeName.length;i++) {
            if (name.equals(myLikeName[i])){
                System.out.println("找到地址了：" + i);
            break;
        }
        }
    }

    public void setMyNumber(){
        for(int i=0;i<(myNumber.length);i++)
            for(int n=0;n<myNumber[i].length;n++)
                System.out.println(myNumber[i][n]);
    }

    public void myFinalGrade(){
        Scanner scan = new Scanner(System.in);
        int finalGrade = scan.nextInt();
        System.out.println("我的期末成绩是："+finalGrade);
    }

    public void sortMyNumber(){
        for(int i=0;i<myNumber1.length-1;i++)
            for(int n=0;n<myNumber1.length-1;n++){
                if (myNumber1[n] > myNumber1[n+1]) {
                    int temp = myNumber1[n];
                    myNumber1[n]=myNumber1[n+1];
                    myNumber1[n+1]=temp;
                }
            }
        for (int x=0;x<myNumber1.length;x++) {
            System.out.println(myNumber1[x]+"\n");
        }
    }
}

